<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% if @assignment.title.nil? %>
  <% content_for :page_title, t("Create Assignment") %>
<% else %>
  <% content_for :page_title, t("Edit Assignment") %>
<% end %>
<% content_for :right_side do %>
  <%= render "shared/wiki_sidebar" %>
<% end %>

<%
  css_bundle :assignments, :assignments_edit, :tinymce
  js_bundle :assignment_edit
%>

<% if @assignment.omit_from_final_grade %>
  <div class="alert alert-info omit-from-final-warning">
    {{#t}}This assignment does not count toward the final grade.{{/t}}
  </div>
<% end %>

<% if ConditionalRelease::Service.enabled_in_context?(@context) %>
<div id="edit_assignment_header-cr" class="header-bar"></div>
<% else %>
<div id="edit_assignment_header" class="<%= 'no-line' if @assignment.quiz_lti? %> header-bar"></div>
<% end %>

<%= render "shared/select_content_dialog", :only => [:external_tools], lti_app_placements: [Lti::ResourcePlacement::ASSIGNMENT_SELECTION, Lti::ResourcePlacement::RESOURCE_SELECTION] %>
<div id="edit_letter_grades_form" style="display: none;">
  <%= render partial: "shared/grading_standard", object: @assignment.grading_standard, locals: {read_only: false} %>
  <a href="<%= context_url(@context, :context_grading_standards_url) %>" style="display: none;" class="create_grading_standard_url">&nbsp;</a>
  <a href="<%= context_url(@context, :context_grading_standard_url, "{{ id }}") %>" style="display: none;" id="update_grading_standard_url">&nbsp;</a>
</div>

<% if @assignment.quiz_lti? && @assignment.persisted? %>
  <div class="ic-Label header-bar">
  <%= t 'links.add_rubric', "Rubric" %>
  </div>
  <% if can_do(@assignment, @current_user, :update) %>
    <div class="content-box">
      <a
        href="<%= context_url(@context, :context_rubrics_url) %>"
        class="add_rubric_link Button icon-plus"
        style="<%= hidden if @assignment.rubric_association %>"
        role="button"
      >
        <span aria-hidden="true"><%= t 'links.add_rubric', "Rubric" %></span>
        <span class="screenreader-only">{{#t}}Add Rubric{{/t}}</span>
      </a>
    </div>
  <% end %>
  <%= render partial: "shared/rubrics_component" %>
<% end %>